package com.hrt.datasender.web.bcaccesstable;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import com.btcode.web.core.annotation.RequestMapping;
import com.btcode.web.core.controller.Controller;
import com.hrt.common.web.DSRequestUnit;
import com.hrt.datasender.datadao.model.BcAccessTableModel;
import com.hrt.datasender.datadao.service.BcAccessTableService;

/**
 * 
 * <pre>
 * 注释
 * </pre>
 * 
 * @author FAN
 * @date 2018年9月12日下午5:25:35
 */
@RequestMapping(path = "BcAccessTable")
public class BcAccessTableController extends Controller {

    @RequestMapping(path = "getModels")
    public void getModel(ServletRequest arg0, ServletResponse arg1) throws IOException {

        List<BcAccessTableModel> model = BcAccessTableService.getInstance().getModels();

        success(model);
    }

    @RequestMapping(path = "create")
    public void saveModel(ServletRequest arg0, ServletResponse arg1) throws IOException {

        BcAccessTableModel accessModel = DSRequestUnit.getModel(BcAccessTableModel.class);
        accessModel = BcAccessTableService.getInstance().create(accessModel);

        success(accessModel);
    }

    @RequestMapping(path = "update")
    public void updateModel(ServletRequest arg0, ServletResponse arg1) throws IOException {

        BcAccessTableModel accessModel = DSRequestUnit.getModel(BcAccessTableModel.class);
        accessModel = BcAccessTableService.getInstance().update(accessModel);

        success(accessModel);
    }

    @RequestMapping(path = "delete")
    public void deleteModel(ServletRequest arg0, ServletResponse arg1) throws IOException {

        String id = DSRequestUnit.getString("id");
        BcAccessTableService.getInstance().delete(id);
        success("");

    }

}
